#!/bin/bash

# 运维发布系统启动脚本

echo "正在启动运维发布系统..."

# 检查Docker是否运行
if ! docker info > /dev/null 2>&1; then
    echo "错误: Docker未运行，请先启动Docker"
    exit 1
fi

# 检查Docker Compose是否安装
if ! command -v docker-compose &> /dev/null; then
    echo "错误: Docker Compose未安装"
    exit 1
fi

# 创建必要的目录
mkdir -p logs
mkdir -p data/postgres
mkdir -p data/redis
mkdir -p data/prometheus
mkdir -p data/grafana

# 设置权限
chmod 755 data/postgres
chmod 755 data/redis
chmod 755 data/prometheus
chmod 755 data/grafana

# 启动服务
echo "启动Docker Compose服务..."
docker-compose up -d

# 等待服务启动
echo "等待服务启动..."
sleep 30

# 检查服务状态
echo "检查服务状态..."
docker-compose ps

# 显示访问信息
echo ""
echo "=========================================="
echo "运维发布系统启动完成！"
echo "=========================================="
echo "Web界面: http://localhost:3000"
echo "API文档: http://localhost:8000/docs"
echo "监控面板: http://localhost:3001"
echo "Flower监控: http://localhost:5555"
echo ""
echo "默认管理员账号:"
echo "用户名: admin"
echo "密码: admin123"
echo "=========================================="
